/*
 * Copyright 2008 Jeff Dwyer
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.apress.progwt.server.domain;

import java.util.Iterator;
import java.util.List;

import com.apress.progwt.client.domain.School;
import com.apress.progwt.client.domain.User;
import com.apress.progwt.client.domain.dto.PostsList;
import com.apress.progwt.client.domain.forum.RecentForumPostTopic;
import com.apress.progwt.server.service.SchoolService;
import com.apress.progwt.server.service.UserService;

import edu.rpi.bt.client.domain.Comment;
import edu.rpi.bt.client.domain.Destination;
import edu.rpi.bt.server.service.DestinationService;

public class FrontPageData {

    private List<School> topSchools;
    private List<SchoolPopularity> popularSchools;
    private List<User> topUsers;
    private PostsList postList;
private List<Destination> destinations;
private List<Destination> trips;
private List<Destination> locations;
private List<Comment> comments;
//private List<String> iURLs;

public FrontPageData(UserService userService,
        SchoolService schoolService) {

    setTopSchools(schoolService.getTopSchools(0, 10));
    setPopularSchools(schoolService.getPopularSchools());

    setTopUsers(userService.getTopUsers(5));

    setPostList(schoolService.getForum(new RecentForumPostTopic(), 0,
            10));

    
}

    public FrontPageData(UserService userService,
            SchoolService schoolService, DestinationService destinationService) {

        setTopSchools(schoolService.getTopSchools(0, 10));
        setPopularSchools(schoolService.getPopularSchools());

        setTopUsers(userService.getTopUsers(5));

        setPostList(schoolService.getForum(new RecentForumPostTopic(), 0,
                10));

        setDestinations(destinationService.getAllDestinations());
        setTrips(destinationService.getTrips());
        setLocations(destinationService.getAllLocations());
        
        setComments(destinationService.getNComments(10));
        
       // setImages(destinationService.getImages());
        
        System.out.println("in frontpage constr");
    }

    
    public List<School> getTopSchools() {
        return topSchools;
    }

    public void setTopSchools(List<School> topSchools) {
        this.topSchools = topSchools;
    }
    
    public void setDestinations(List<Destination> destinations) {
        this.destinations = destinations;
    }
    public List<Destination> getDestinations() {
        return destinations;
    }
    
    public void setTrips(List<Destination> trips) {
        this.trips = trips;
    }
    public List<Destination> getTrips() {
        return trips;
    }
    
    public void setLocations(List<Destination> locations) {
        for (Iterator it = locations.iterator(); it.hasNext(); ) {
            Destination location = (Destination)it.next();
 //           System.out.println("FP " + location.getUstring());
   //         System.out.println("FP " + location.getIURL());
        }
        this.locations = locations;
    }
    public List<Destination> getLocations() {
        return locations;
    }
    
    public List<Comment> getComments() {
        return comments;
    }
    public void setComments(List<Comment> comments) {
        this.comments = comments;
    }
    
    /*
    public List<String> getImages() {
        return iURLs;
    }
    public void setImages(List<String> images) {
        this.iURLs = iURLs;
    }
    */
    public List<SchoolPopularity> getPopularSchools() {
        return popularSchools;
    }

    public void setPopularSchools(List<SchoolPopularity> popularSchools) {
        this.popularSchools = popularSchools;
    }

    public List<User> getTopUsers() {
        return topUsers;
    }

    public void setTopUsers(List<User> topUsers) {
        this.topUsers = topUsers;
    }

    public PostsList getPostList() {
        return postList;
    }

    public void setPostList(PostsList postList) {
        this.postList = postList;
    }

}
